﻿
using CSharpLibs.Annotations;

namespace System
{
	[Builtin]
	public struct TimeSpan : IComparable<TimeSpan>, IEquatable<TimeSpan>
	{
		internal long _ticks;

		public TimeSpan(long ticks)
		{ this._ticks = ticks; }

		public TimeSpan(int hours, int minutes, int seconds)
		{ this._ticks = TimeToTicks(hours, minutes, seconds); }

		public TimeSpan Add(TimeSpan ts)
		{
			long ticks = this._ticks + ts._ticks;
			return new TimeSpan(ticks);
		}

		public int CompareTo(TimeSpan value)
		{
			long num = value._ticks;
			if(this._ticks > num)
			{
				return 1;
			}
			if(this._ticks < num)
			{
				return -1;
			}
			return 0;
		}

		public override bool Equals(object value)
		{
			return ((value is TimeSpan) && (this._ticks == ((TimeSpan)value)._ticks));
		}

		public bool Equals(TimeSpan obj)
		{
			return (this._ticks == obj._ticks);
		}

		public override int GetHashCode()
		{
			return (((int)this._ticks) ^ ((int)(this._ticks >> 0x20)));
		}

		internal static long TimeToTicks(int hour, int minute, int second)
		{
			long num = ((hour * 0xe10L) + (minute * 60L)) + second;
			return (num * 0x989680L);
		}

		public TimeSpan Subtract(TimeSpan ts)
		{
			long ticks = this._ticks - ts._ticks;
			return new TimeSpan(ticks);
		}

		public int Days
		{ get { return (int)(this._ticks / 0xc92a69c000L); } }

		public int Hours
		{ get { return (int)((this._ticks / 0x861c46800L) % 0x18L); } }

		public int Minutes
		{ get { return (int)((this._ticks / 0x23c34600L) % 60L); } }

		public int Seconds
		{ get { return (int)((this._ticks / 0x989680L) % 60L); } }

		public long Ticks
		{ get { return this._ticks; } }
	}
}
